home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 796 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  5.5 KB

  1. Path: cs.uwa.edu.au!jasonb
  2. From: jasonb@cs.uwa.edu.au (Jason S Birch)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 11 Jan 96 14:44:28 GMT
  6. Organization: The University of Western Australia
  7. Message-ID: <jasonb.821371468@cs.uwa.edu.au>
  8. References: <john.hendrikx.40ka@grafix.xs4all.nl> <jasonb.820051107@cs.uwa.edu.au> <VBzVx*M3f@yaps.rhein.de> <4d0tf0$i4i@maureen.teleport.com>
  9. NNTP-Posting-Host: decadence.cs.uwa.oz.au
  10. X-Newsreader: NN version 6.5.0 #3 (NOV)
  11.  
  12. sschaem@teleport.com (Stephan Schaem) writes:
  13.  
  14. >Arno Eigenwillig (arno@yaps.rhein.de) wrote:
  15. >: Don't distract, this was not the point. Intentional misunderstandings
  16. >: prove nothing.
  17.  
  18. > It was about: "C is better because you dont need to know your variable type"
  19.  
  20. No, it wasn't, which is what I've been repeatedly saying. It was about
  21. whether assembler is easier to debug than C because the line:
  22.  
  23. move.w (a0)+,(a1)+ 
  24.  
  25. tells you how many bytes are being moved, and added to a0 and a1,
  26. whereas:
  27.  
  28. *a++ = *b++;
  29.  
  30. does not. Many of us said "no", not least because the assembler line
  31. doesn't tell you whether you *wanted* to move two bytes or not unless
  32. you know what a0 and a1 are pointing to. You need to know that to know
  33. if it's correct, just as you need to know that *a and *b are the same
  34. type, although in the C case you *don't* need to know how many bytes
  35. are moved or added to a and b - you don't need to know how the types
  36. are *implemented*, and the claim was made that, in any case, you could
  37. pretty much rely on C to complain if you make a mistake. This is where
  38. you came in. Note the difference between "not needing to know your
  39. variable type" and "not needing to know how that variable type is
  40. implemented on a particular hardware/OS/compiler implementation".
  41.  
  42. >: What are you talking about? <time.h> is provided as part of the
  43. >: compiler. The compiler is a beast that translates a valid C source
  44. >: code defining an algorithm for an abstract machine into actual machine
  45. >: code for an actual machine.
  46.  
  47. > I'm talking about doing operation on a strcuture element. if the element
  48. > was defined has a ulong, then one decide its a float you will have to
  49. > update your code too to use float. 
  50.  
  51. This is a red herring. If the *type* of an element in a structure is
  52. given as ulong, then it must be a ulong, it is bound to being a ulong,
  53. and you can forever more treat it as a ulong. If it's given as a
  54. bilby, however, and somewhere else a bilby is defined to be a ulong
  55. (via typedef), then it is only bound to being a bilby and you can only
  56. treat it like a bilby - you may not treat it as a ulong.
  57.  
  58. Note well, however, that even ulong is an abstract type, and the only
  59. assumptions you can make about it are those guaranteed by ANSI
  60. (assuming you want portability, of course). In particular, it is *not*
  61. guaranteed to be a 32 bit unsigned integer. On a DEC Alpha, for
  62. example, it's 64 bits. On a 16 bit machine, it could well be 16 bits.
  63. Look at integer for another example - on a 68000 Amiga with SAS/C, it
  64. defaults to 32 bits; specify SHORTINTEGERS and it's 16 bits. On a Mac,
  65. it's 16 bits. Win16 code on a PC, it's 16 bits; compile for Win32 and
  66. it's 32 bits. The reason for not specifying these sizes is efficiency
  67. - leaving them undefined allows the compiler writer to choose the most
  68. efficient representation. Unfortunately, it requires the programmer to
  69. do more work to make sure the types can hold the values required. It
  70. would make writing portable code easier if there were int16, int32,
  71. int64, etc, types, but this is a side issue. :-)
  72.  
  73. >: Then there is clock_t (and similar beasts like size_t, prtdiff_t).
  74. >: clock_t is a typedef for one out of a set of simple types, but it is
  75. >: not said which one. Again, there are objects of type clock_t and
  76. >: operations defined for them with specific semantics.
  77.  
  78. > I dont rememner reading clock_t was a type of type ulong... 
  79.  
  80. From SAS/C's time.h:
  81. typedef unsigned long clock_t;
  82.  
  83. However, it doesn't matter.
  84.  
  85. >: The idea behind clock_t is that it is a data type suitable for storage
  86. >: of the system's clock's value and certain operations on it. These
  87. >: operations are defined in an abstract way, independant of a specific
  88. >: choice what simple type clock_t may actually be.
  89.  
  90. > you might not care clockt_t went from 32bit long to a 64bit long,
  91. > but I you would if it become a 32digit bcpl.
  92.  
  93. It couldn't, because "-" would no longer work; however, if a
  94. DiffClock() function existed, it could. time_t is a better example.
  95.  
  96. >: The obvious advantage is that these conception of the abstract machine
  97. >: allows C source code to be portable to many different actual machines,
  98. >: no matter what strange encoding they use for clock_t.
  99.  
  100. > No matter what strnage encoding... how about a pointer to a string?
  101.  
  102. Again, time_t is a better example. clock_t must be an ordinal type.
  103.  
  104. >: Dave called it "polymorphism". I call it "data encapsulation". Anyway,
  105. >: it's a basic concept of decent programming, and not having understood
  106. >: it is no crime, but one probably shouldn't go around demonstrating it
  107. >: everywhere in the most embarrassing way. Eh?
  108.  
  109. > The point he wanted to prove is that you dont need to care about your
  110. > variable type, and your variable type definition. I just desagree.
  111.  
  112. This is the problem - he never wanted to prove that. You misinterpreted
  113. his comments, and have thus far refused to give up your straw man. :-)
  114.  
  115. > Stephan
  116.  
  117. -- 
  118. Jason S Birch                        ,-_|\ email: jasonb@cs.uwa.edu.au
  119. Department of Computer Science      /     \ Tel (work): +61 9 380 1840
  120. The University of Western Australia *_.-._/ Fax (work): +61 9 380 1089
  121. Nedlands  W. Australia  6907             v  Tel (home): +61 9 386 8630
  122.